// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   OptReviewAction.java

package com.boci.clientapp.trading.action;

import com.boci.clientapp.main.ApplicationService;
import com.boci.clientapp.main.MainPanel;
import com.boci.clientapp.trading.*;
import com.boci.clientapp.trading.handler.OptionHandler;
import com.boci.common.action.AbstractAction;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.util.AppException;
import com.boci.common.util.StringUtil;
import java.util.HashMap;
import java.util.logging.Logger;

public class OptReviewAction extends AbstractAction
{

    public OptReviewAction()
    {
        strModName = "TRADING_MODULE";
        strOptionScr = "OPTION_SCREEN";
        strOptReviewScr = "REVIEW_OPTION_SCREEN";
        strOptConfirmScr = "CONFIRM_OPTION_SCREEN";
    }

    private void addExtraValues(HashMap pInpMap)
    {
        pInpMap.put("acctid", appServ.getAccountNo());
        pInpMap.put("userid", appServ.getUserID());
        pInpMap.put("sendValue", "Send Order");
    }

    public void doProcess(HashMap pInpMap, String pActionType)
    {
    	try{
	        appServ.setBusy(true);
	        OptionScrPanel trdPanel = (OptionScrPanel)appServ.getMainPanel().getPanel(strModName, strOptionScr);
	        if(pActionType.equals("BACK"))
	            doBack(pInpMap, trdPanel);
	        else
	        if(pActionType.equals("CANCEL"))
	            doCancel(trdPanel);
	        else
	        if(pActionType.equals("SEND ORDER"))
	            doSendOrder(pInpMap, trdPanel);
	        OptReviewScrPanel reviewPanel = (OptReviewScrPanel)appServ.getMainPanel().getPanel(strModName, strOptReviewScr);
	        reviewPanel.resetDuplicateFlag();
    	}
        catch(AppException appEx)
        {
            logger.info(StringUtil.formatException(appEx));
            if(appEx.getErrorCode().equals("TRD00998") || appEx.getErrorCode().equals("TRD00999"))
            {
                OptReviewScrPanel reviewPanel = (OptReviewScrPanel)appServ.getMainPanel().getPanel(strModName, strOptReviewScr);
                reviewPanel.acceptDuplicate();
                appServ.showWarningDialog(null, appEx.getMessage());
            } else
            {
                appServ.showErrorDialog(null, appEx.getMessage());
            }
        }
        catch(Exception sysEx)
        {
            logger.severe(StringUtil.formatException(sysEx));
            appServ.showSysErrDialog();
        }
        finally
        {
            appServ.setBusy(false);
        }
        return;
    }

    private void doSendOrder(HashMap pInpMap, OptionScrPanel pOptionScrPanel)
        throws Exception
    {
        addExtraValues(pInpMap);
        if(pOptionScrPanel.getHKOptFlag())
        {
            String strReqType = RequestTypeConst.BOCI_HK_OPTION_SEND_URL;
            OptionHandler optionHandler = new OptionHandler(strReqType);
            OptConfirmScrPanel confirmPanel = (OptConfirmScrPanel)appServ.getMainPanel().getPanel(strModName, strOptConfirmScr);
            confirmPanel.refresh(optionHandler.sendHKOption(pInpMap));
            appServ.getMainPanel().showScreen(strModName, strOptConfirmScr);
        } else
        {
            String strReqType = RequestTypeConst.BOCI_US_OPTION_SEND_URL;
            OptionHandler optionHandler = new OptionHandler(strReqType);
            OptConfirmScrPanel confirmPanel = (OptConfirmScrPanel)appServ.getMainPanel().getPanel(strModName, strOptConfirmScr);
            confirmPanel.refresh(optionHandler.sendUSOption(pInpMap));
            appServ.getMainPanel().showScreen(strModName, strOptConfirmScr);
        }
    }

    private void doCancel(OptionScrPanel pOptionScrPanel)
        throws Exception
    {
        pOptionScrPanel.refresh();
        appServ.getMainPanel().showScreen("ORDER_STATUS_MODULE", "ORDER_STATUS_SCREEN");
    }

    private void doBack(HashMap pInpMap, OptionScrPanel pOptionScrPanel)
        throws Exception
    {
        TradingTabSclPane tradingSclPane = (TradingTabSclPane)appServ.getMainPanel().getTab(strModName);
        tradingSclPane.backToOptionScreen();
    }

    String strModName;
    String strOptionScr;
    String strOptReviewScr;
    String strOptConfirmScr;
}
